import { createAsyncThunk } from '@reduxjs/toolkit'
import Api from '@API'
import { actions, DEMO } from '@REDUX/reducer/demo'
import { useAppDispatch } from '@REDUX/store'

const fetchDemo = createAsyncThunk('demo/fetchDemo', async () => {
  const dispatch = useAppDispatch()
  const response = await Api.requestAuthCode({ PhoneNumber: '18236593093' })
  if (response.data.isDo) {
    dispatch(actions[DEMO.SUCCESS]())
  }
  return response.data
})
export default fetchDemo
